<template>
  <div class="detail">
    <div v-for="item in dtailData" :key="item.category_id">
      <div class="det-hd">
        <div class="hd-box">
          <div class="title">{{ item.product_name }}</div>
          <div class="dat_list">
            <ul>
              <li><router-link to="">概念</router-link></li>
              <li><router-link to="">参数</router-link></li>
              <li><router-link to="">用户评价</router-link></li>
            </ul>
          </div>
        </div>
      </div>
      <div class="det_box">
        <!-- 轮播 -->
        <div class="carouse">
          <el-carousel height="560px">
            <el-carousel-item v-for="item in pictureArry" :key="item.id">
              <img :src="$target + item.product_picture" alt="" />
            </el-carousel-item>
          </el-carousel>
        </div>
        <!-- 介绍 -->
        <div class="text">
          <h1>{{ item.product_name }}</h1>
          <p class="intro">{{ item.product_intro }}</p>
          <p class="store">小米自营</p>
          <div class="price">
            <span>{{ item.product_selling_price }}元</span>
            <del v-if="item.product_selling_price != item.product_price"
              >{{ item.product_price }}元</del
            >
          </div>
          <div class="pro-list">
            <span class="pro-name">{{ item.product_name }}</span>
            <span class="pro-price">
              <span>{{ item.product_selling_price }}元</span>
              <del>{{ item.product_price }}元</del>
            </span>
            <p class="price-sum">总计：{{ item.product_selling_price }}元</p>
          </div>
          <div class="button">
            <button class="shop-cart">加入购物车</button>
            <button class="shop-like">喜欢</button>
          </div>
          <div class="pro-policy">
            <ul>
              <li>
                <i class="el-icon-circle-check"><span>小米自营</span></i>
              </li>
              <li>
                <i class="el-icon-circle-check"><span>小米发货</span></i>
              </li>
              <li>
                <i class="el-icon-circle-check"><span>7天无理由退货</span></i>
              </li>
              <li>
                <i class="el-icon-circle-check"><span>7天价格保护</span></i>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import axios from '../api/detailsApi'
export default {
  name: 'Details',
  data() {
    return {
      dtailData: [],
      pictureArry: [],
    }
  },
  created () {
     this.detailData(this.$route.query)
  },
  methods: {
    //  获取详情数据
    async detailData(data) {
      let res= await axios.getDetails(data)
      this.dtailData = res.Product
      // 获取轮播图数据
      let { data: res1 } = await axios.getDetailsPicture(data)
      this.pictureArry = res1.ProductPicture
      // console.log(res.Product)
    },
  },
}
</script>
<style lang="scss" scoped>
.det-hd {
  height: 64px;
  z-index: 4;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  // -webkit-box-shadow: 0 5px 5px rgb(0 0 0 / 7%);
  -webkit-box-shadow: 0 5px 5px #eee;
  // box-shadow: 0 5px 5px rgb(0 0 0 .3);
  box-shadow: 0 5px 5px #eee;
}
.hd-box {
  max-width: 1310px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  .title {
    line-height: 64px;
    font-size: 18px;
    font-weight: 400;
    color: #212121;
  }
  .dat_list {
    ul {
      display: flex;
      a {
        line-height: 64px;
        font-size: 18px;
        font-weight: 400;
        color: #212121;
        margin-left: 20px;
      }
      a:hover {
        color: #ff6700;
      }
    }
  }
}
.det_box {
  max-width: 1225px;
  margin: 30px auto;
  display: flex;
  .carouse {
    width: 560px;
    height: 560px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .text {
    width: 640px;
    h1 {
      height: 30px;
      line-height: 30px;
      font-size: 24px;
      font-weight: 400;
      color: #212121;
    }
    .intro {
      color: #b0b0b0;
      padding-top: 10px;
    }
    .store {
      color: #ff6700;
      padding-top: 10px;
    }
    .price {
      display: block;
      font-size: 18px;
      color: #ff6700;
      border-bottom: 1px solid #e0e0e0;
      padding: 25px 0 25px;
      del {
        font-size: 14px;
        margin-left: 10px;
        color: #b0b0b0;
      }
    }
    .pro-list {
      background: #f9f9fa;
      padding: 30px 60px;
      margin: 50px 0 50px;
      .pro-name {
        line-height: 30px;
        color: #616161;
      }
      .pro-price {
        float: right;
        line-height: 30px;
        color: #616161;
        del {
          margin-left: 15px;
        }
      }
      .price-sum {
        color: #ff6700;
        font-size: 24px;
        padding-top: 20px;
      }
    }
    .button {
      height: 55px;
      margin: 10px 0 20px 0;
      .shop-cart,
      .shop-like {
        float: left;
        height: 55px;
        line-height: 55px;
        font-size: 16px;
        color: #fff;
        border: none;
        text-align: center;
        border-radius: 3px;
      }
      .shop-cart {
        width: 340px;
        background-color: #ff6700;
      }
      .shop-like {
        width: 260px;
        margin-left: 40px;
        background-color: #b0b0b0;
      }
    }
    .pro-policy {
      li {
        float: left;
        margin-right: 20px;
        color: #b0b0b0;
        span {
          margin-left: 10px;
        }
      }
    }
  }
}
</style>